<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/7/6 0006
 * Time: 10:12
 */

namespace api\storage\model;


use think\Model;

class TransferModel extends Model
{
    protected $table = "smt_transfer";
    protected $uuid = "uuid";

    /***+
     * @param $data
     * @return int|string
     * 新增一条transfer
     */
    public function add($data){
        $result = $this->insert($data);
        return $result;
    }

    public function findReel($where){
        $result = $this
            -> where($where)
            -> find();
        return $result;
    }

    public function findDestination($where){
        $result = $this->alias("transfer")
            ->join(['smt_feed_station_detail' => 'b'],"transfer.feed_detail_uuid = b.uuid")
            ->join(['smt_machine' => 'machine'],"b.machine_id = machine.machine_id")
            ->field('b.feed_id feedId,b.machine_id machineId,b.seat_code seatCode,machine.status machineStatus,transfer.uuid transferUuid')
            ->where($where)
            ->find();
        return $result;
    }

    public function deleteByUuid($uuid){
        $where['uuid'] = $uuid;
        $result = $this->where($where)->delete();
        return $result;
    }

}